﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text.RegularExpressions;
using System.Web;
using LYWebsite.Models;

namespace LYWebsite.Helper
{
    public class VerificationHelper
    {
        public static int CarNum = int.Parse(ConfigurationManager.AppSettings["CarNum"]);
        public static string VerifyLogin(LoginModel loginModel)
        {
            var isNotTel = !Regex.IsMatch(loginModel.PhoneNumber??string.Empty.Trim(), @"^[1][3-5,8]\d{9}$");
            if (isNotTel)
                return "~/Views/Verify/PNError.cshtml";

            var isNotName = string.IsNullOrEmpty(loginModel.UserName ?? string.Empty.Trim());
            if(isNotName)
                return "~/Views/Verify/UNError.cshtml";


            var isSetCar = loginModel.CarId != 0 && loginModel.CarId <= CarNum;
            if (!isSetCar)
                return "~/Views/Verify/CTError.cshtml";
            
            return string.Empty;

        }

        //public static string VerifyChargeLogin(ChargeModel chargeModel)
        //{
        //    var isNotTel = !Regex.IsMatch(chargeModel.PhoneNumber ?? string.Empty.Trim(), @"^[1][3-5,8]\d{9}$");
        //    if (isNotTel)
        //        return "~/Views/Verify/PNError.cshtml";

        //    var isNotName = string.IsNullOrEmpty(chargeModel.UserName ?? string.Empty.Trim());
        //    if (isNotName)
        //        return "~/Views/Verify/UNError.cshtml";
        //    return string.Empty;

        //}
    }
}